<style lang="less">
    @import './login.less';
</style>

<template>
    <div class="login" :style="note">
        <div class="login-con">
            <Card>
                <div class="login-con-header" slot="title">
                    <Icon type="md-log-in"/>
                    欢迎登录
                </div>
                <div class="form-con">
                    <login-form @on-success-valid="handleSubmit"></login-form>
                    <p class="login-tip">输入任意用户名和密码即可</p>
                </div>
            </Card>
        </div>
    </div>
</template>

<script>
    import LoginForm from '_c/login-form'
    import {mapActions} from 'vuex'
    import baseURL from '_conf/url'

    export default {
        data(){
            return{
                note: {
                    backgroundImage: "url(" + require("../../assets/images/login-bg.jpg") + ")"
                }
            }
        },
        components: {
            LoginForm
        },
        methods: {
            ...mapActions([
                'handleLogin',
                'getUserInfo'
            ]),
            handleSubmit({username, password}) {
                this.handleLogin({username, password}).then(res => {
                    this.getUserInfo().then(res => {
                        this.$router.push({
                            name: 'home'
                        })
                    })
                })
            }
        },
        created() {
            console.log(location.hostname);
            let params={};
            params.propertyNo=location.hostname;
            this.postRequest("/api/dept/getPropertyInfo", params).then(res => {
                console.log(res);
                if(res.code==20000 && res.data != null){
                    let loginPic=res.data.loginPic
                    this.note.backgroundImage="url(" + loginPic + ")"
                }
            });
            // console.log(location.hostname);
            // this.$axios.request({
            //     url: '/user/login',
            //     data: {
            //         username: 123,
            //         password: 456
            //     },
            //     method: 'post'
            // })
        }
    }
</script>

<style>

</style>
